package com.dd.dc.entity.users;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.dd.dc.base.domain.DBaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;


/**
 * <p>
 * 用户信息表
 * </p>
 *
 * @author JueDream
 * @since 2021-03-05
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("D_USER")
@ApiModel(value="DUser对象", description="用户信息表")
public class DUser extends DBaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户编号")
    @TableId(value = "USER_ID", type = IdType.AUTO)
    private Integer userId;

    @ApiModelProperty(value = "用户名称")
    @TableField("USER_NAME")
    private String userName;

    @ApiModelProperty(value = "用户性别（0-男；1-女 2-其他）")
    @TableField("USER_SEX")
    private Integer userSex;

    @ApiModelProperty(value = "用户联系方式")
    @TableField("USER_PHONE")
    private String userPhone;

    @ApiModelProperty(value = "用户登录账户")
    @TableField("USER_ACCOUNT")
    private String userAccount;

    @ApiModelProperty(value = "用户备注")
    @TableField("USER_REMARK")
    private String userRemark;

    @ApiModelProperty(value = "用户最后登录时间")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    @TableField("USER_LOGIN_TIME")
    private LocalDateTime userLoginTime;

    @ApiModelProperty(value = "用户VIP等级")
    @TableField("USER_LEVEL_ID")
    private Integer userLevelId;

    @ApiModelProperty(value = "用户登录密码")
    @TableField("USER_PASSWORD")
    private String userPassword;

    @ApiModelProperty(value = "用户角色")
    @TableField(exist = false)
    private List<DRole> roles = new ArrayList<>();

    @ApiModelProperty(value = "用户权限")
    @TableField(exist = false)
    private List<DPermission> permissions = new ArrayList<>();

    public DUser(){}

    @Builder
    public DUser(Integer userId, String userName, Integer userSex, String userPhone, String userAccount, String userRemark, LocalDateTime userLoginTime, Integer userLevelId, Integer delFlg, String createBy, LocalDateTime createTime, String updateBy, LocalDateTime lastUpdateTime, String userPassword, List<DRole> roles, List<DPermission> permissions) {
        this.userId = userId;
        this.userName = userName;
        this.userSex = userSex;
        this.userPhone = userPhone;
        this.userAccount = userAccount;
        this.userRemark = userRemark;
        this.userLoginTime = userLoginTime;
        this.userLevelId = userLevelId;
        this.delFlg = delFlg;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.lastUpdateTime = lastUpdateTime;
        this.userPassword = userPassword;
        this.roles = roles;
        this.permissions = permissions;
    }
}
